package com.wxc.wxcwzq.web.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wxc.wxcwzq.core.entity.Employee;
import com.wxc.wxcwzq.web.entity.SysPermission;
import com.wxc.wxcwzq.web.entity.SysRoles;
import com.wxc.wxcwzq.web.mapper.SysPermissionMapper;
import com.wxc.wxcwzq.web.mapper.SysRolesMapper;

/**
 * 
 */
@Service
public class SysPermissionService {
	
	@Autowired
	private SysPermissionMapper permissionMapper;
	
	/**
	 * 返回所有
	 * @param roles
	 * @param pageNum 页码
	 * @param pageSize 每页显示多少条
	 * @return
	 */
	public Page<SysPermission>queryAllRoleInfo(SysPermission permission,Integer pageNum, Integer pageSize){
//		Page<Employee> page = new Page<>();
		PageHelper.startPage(pageNum,pageSize);
		Page<SysPermission> list = permissionMapper.queryAllRoleInfo(permission);
		return list;
	}
	
	/**
	 * 根据id查询
	 * @param id
	 * @return
	 */
	public SysPermission getRoleInfo(Long id){
		return permissionMapper.selectByPrimaryKey(id);
	}
	/**
	 * 根据角色id查询权限
	 * @param roleId
	 * @return
	 */
	public List<SysPermission> selectPerByRoleId(Long roleId){
		
		return permissionMapper.selectPerByRoleId(roleId);
	}
	/**
	 * 添加
	 * @param roles 
	 * @return
	 */
	public Integer addRoles(SysPermission permission){
		return permissionMapper.insertPermission(permission);
	}
	/**
	 * 修改
	 * @param roles
	 * @return
	 */
	public Integer updateRoles(SysPermission permission){
		return permissionMapper.updatePermission(permission);
	}
	/**
	 * 逻辑删除
	 * @param id
	 * @return
	 */
	public Integer deleteRoles(Long id){
		return permissionMapper.deletePermission(id);
	}
	
	
	
}
